// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'
import { bxAnaalyse } from '@/core/icons'

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: 'menu.home' },
    redirect: '/dashboard/workplace',
    children: [
      // dashboard
      {
        path: '/dashboard',
        name: 'dashboard',
        redirect: '/dashboard/workplace',
        component: RouteView,
        meta: { title: 'menu.dashboard', keepAlive: true, icon: bxAnaalyse, permission: ['dashboard'] },
        children: [
          {
            path: '/dashboard/workplace',
            name: 'Workplace',
            component: () => import('@/views/dashboard/Workplace'),
            meta: { title: 'menu.dashboard.workplace', keepAlive: true, permission: ['dashboard'] }
          }
        ]
      },
      // 志愿者管理
      {
        path: '/admin/volunteer',
        name: 'adminVolunteer',
        component: RouteView,
        redirect: '/admin/volunteer/list',
        meta: { title: 'menu.volunteer', icon: 'user', permission: ['volunteer'] },
        children: [
          {
            path: '/admin/volunteer/list',
            name: 'adminVolunteerIndex',
            component: () => import('@/views/admin.volunteer/volunteer'),
            meta: { title: 'menu.volunteer.list', permission: ['volunteer.lists'] }
          },
          {
            path: '/admin/volunteer/opera-detail',
            name: 'adminVolunteerOperaDetail',
            component: () => import('@/views/admin.volunteer/opera-detail'),
            meta: { title: '志愿者操作详情', permission: ['volunteer'] },
            hidden: true
          }
        ]
      },
      // 服务管理
      {
        path: '/admin/service',
        name: 'adminService',
        component: RouteView,
        redirect: '/admin/service/classify',
        meta: { title: 'menu.admin.service', icon: 'cloud', permission: ['service'] },
        children: [
          {
            path: '/admin/service/classify',
            name: 'adminServiceClassify',
            component: () => import('@/views/admin.service/classify'),
            meta: { title: 'menu.admin.service.classify', permission: ['service.list'] }
          },
          {
              path: '/admin/service/content',
              name: 'adminServiceContent',
              component: () => import('@/views/admin.service/content'),
              meta: { title: 'menu.admin.service.content', permission: ['service_content.list'] }
          }
        ]
      },
      // 服务管理
      {
        path: '/admin/integral',
        name: 'adminIntegral',
        component: RouteView,
        redirect: '/admin/integral/classify',
        meta: { title: 'menu.admin.integral', icon: 'cloud', permission: ['point_option'] },
        children: [
          {
            path: '/admin/integral/index',
            name: 'adminIntegral',
            component: () => import('@/views/admin.integral/index'),
            meta: { title: 'menu.admin.integral.index', permission: ['point_option.list'] }
          }
        ]
      },
      // 问卷
      {
        path: '/admin/exam',
        name: 'adminExam',
        component: RouteView,
        redirect: '/admin/exam/List',
        meta: { title: 'menu.admin.exam', icon: 'code-sandbox', permission: ['survey'] },
        children: [
          {
            path: '/admin/exam/List',
            name: 'adminExamList',
            component: () => import('@/views/admin.exam/List'),
            meta: { title: 'menu.admin.exam.list', permission: ['survey.list'] }
          },
          {
              path: '/admin/exam/sort',
              name: 'adminExamSort',
              component: () => import('@/views/admin.exam/Sort'),
              meta: { title: 'menu.admin.exam.sort', permission: ['survey.class_list'] }
          },
          {
              path: '/admin/exam/AnswerLog',
              name: 'adminExamAnswerLog',
              hidden: true,
              component: () => import('@/views/admin.exam/AnswerLog'),
              meta: { title: 'menu.admin.exam.AnswerLog', permission: ['survey.list'] }
          },
          {
              path: '/admin/exam/QuestionBank',
              name: 'adminExamQuestionBank',
              hidden: true,
              component: () => import('@/views/admin.exam/QuestionBank'),
              meta: { title: 'menu.admin.exam.QuestionBank', permission: ['survey.list'] }
          }
        ]
      },
      // 家风银行
      {
        path: '/admin/bank',
        name: 'adminBank',
        component: RouteView,
        redirect: '/admin/bank/rank-data',
        meta: { title: 'menu.admin.bank', icon: 'bank', permission: ['point'] },
        children: [
          {
            path: '/admin/Inspection/adjust',
            name: 'adminInspection',
            component: RouteView,
            redirect: '@/views/admin.Inspection/adjust',
            meta: { title: 'menu.admin.Inspection', permission: ['point'] },
            children: [
              {
                path: '/admin/Inspection/adjust',
                name: 'adminInspectionAdjust',
                component: () => import('@/views/admin.Inspection/adjust'),
                meta: { title: 'menu.admin.Inspection.adjust', permission: ['point.rectify_list'] }
              },
              {
                path: '/admin/Inspection/distribution',
                name: 'adminInspectionDistribution',
                component: () => import('@/views/admin.Inspection/distribution'),
                meta: { title: 'menu.admin.Inspection.distribution', permission: ['point.rectify_agent_list'] }
              }
            ]
          },
          {
            path: '/admin/CardManage/cardManage',
            name: 'cardManage',
            component: RouteView,
            redirect: '@/views/admin.card/CardList',
            meta: { title: 'menu.admin.bank.card' },
            children: [
              {
                path: '/admin/CardManage/cardList',
                name: 'cardManage',
                component: () => import('@/views/admin.card/CardList'),
                meta: { title: 'menu.admin.bank.card.list' }
              },
              {
                path: '/admin/CardManage/storeList',
                name: 'storeList',
                component: () => import('@/views/admin.card/StoreList'),
                meta: { title: 'menu.admin.bank.card.store' }
              },
              {
                path: '/admin/CardManage/sendHistory',
                name: 'sendHistory',
                component: () => import('@/views/admin.card/SendHistory'),
                meta: { title: 'menu.admin.bank.card.history' }
              },
              {
                path: '/admin/CardManage/cardRules',
                name: 'cardRules',
                component: () => import('@/views/admin.card/CardRules'),
                meta: { title: 'menu.admin.bank.card.rules' }
              }
            ]
          },
          {
            path: '/admin/bank/rank-data',
            name: 'adminBankRankData',
            component: () => import('@/views/admin.bank/rank.data'),
            meta: { title: 'menu.admin.bank.rank.data', permission: ['point.rank_list'] }
          },
          {
            path: '/admin/bank/rank-data-detail',
            name: 'adminBankRankDataDetail',
            hidden: true,
            component: () => import('@/views/admin.bank/rank.data.detail'),
            meta: { title: 'menu.admin.bank.rank.data.detail', permission: ['point'] }
          },
          {
              path: '/admin/bank/rank-rules',
              name: 'adminBankRankRules',
              component: () => import('@/views/admin.bank/rank.rules'),
              meta: { title: 'menu.admin.bank.rank.rules', permission: ['point.get_rule'] }
          },
          {
              path: '/admin/bank/integral',
              name: 'adminBankIntegral',
              component: () => import('@/views/admin.bank/integral'),
              meta: { title: 'menu.admin.bank.integral', permission: ['point.season_count'] }
          },
          {
              path: '/admin/bank/integral.detail',
              name: 'adminBankIntegralDetail',
              component: () => import('@/views/admin.bank/integral.detail'),
              meta: { title: 'menu.admin.bank.integral.detail', permission: ['point.lists'] }
          }
        ]
      },
      // 内容管理
      {
        path: '/admin/content',
        name: 'adminContent',
        component: RouteView,
        redirect: '/admin/content/notice',
        meta: { title: 'menu.admin.content', icon: 'code-sandbox', permission: ['content'] },
        children: [
          {
            path: '/admin/content/notice',
            name: 'adminContentNotice',
            component: () => import('@/views/admin.content/Notice'),
            meta: { title: 'menu.admin.content.notice', permission: ['content.notice.lists'] }
          },
          {
              path: '/admin/content/news',
              name: 'adminContentNews',
              component: () => import('@/views/admin.content/News'),
              meta: { title: 'menu.admin.content.news', permission: ['content.news_bulletin.lists'] }
          },
          {
              path: '/admin/content/activity',
              name: 'adminContentActivity',
              component: () => import('@/views/admin.content/Activity'),
              meta: { title: 'menu.admin.content.activity', permission: ['content.activity.lists'] }
          }
        ]
      },
      // 管理员管理
      {
        path: '/admin/admin',
        name: 'adminAdmin',
        component: RouteView,
        redirect: '/admin/admin/setting',
        meta: { title: 'menu.admin.admin', icon: 'tags', permission: ['user'] },
        children: [
          {
            path: '/admin/admin/setting',
            name: 'adminAdminSetting',
            component: () => import('@/views/admin.admin/setting'),
            meta: { title: 'menu.admin.admin.setting', permission: ['user.admin_list'] }
          }
        ]
      },
      // 角色管理
      {
        path: '/admin/roles',
        name: 'adminRoles',
        component: RouteView,
        redirect: '/admin/roles/setting',
        meta: { title: 'menu.admin.roles', icon: 'link', permission: ['system'] },
        children: [
          {
            path: '/admin/roles/setting',
            name: 'adminRolesSetting',
            component: () => import('@/views/admin.roles/setting'),
            meta: { title: 'menu.admin.roles.setting', permission: ['system.roles_list'] }
          }
        ]
      },
      // 权限管理
      {
        path: '/admin/auth',
        name: 'adminAuth',
        component: RouteView,
        redirect: '/admin/auth/setting',
        hidden: true,
        meta: { title: 'menu.admin.auth', icon: 'menu-unfold', permission: ['auth'] },
        children: [
          {
            path: '/admin/auth/setting',
            name: 'adminAuthSetting',
            component: () => import('@/views/admin.auth/setting'),
            meta: { title: 'menu.admin.auth.setting', permission: ['auth'] }
          }
        ]
      },
      // 日志管理
      {
        path: '/admin/log',
        name: 'adminLog',
        component: RouteView,
        redirect: '/admin/log/setting',
        meta: { title: 'menu.admin.log', icon: 'bug', permission: ['logs'] },
        children: [
          {
            path: '/admin/log/setting',
            name: 'adminLogSetting',
            component: () => import('@/views/admin.log/setting'),
            meta: { title: 'menu.admin.log.setting', permission: ['logs.lists'] }
          }
        ]
      },
      // 修改密码
      {
        path: '/account',
        component: RouteView,
        redirect: '/account/center',
        name: 'account',
        hidden: true,
        meta: { title: 'menu.account', icon: 'user', keepAlive: true, permission: ['user'] },
        children: [
          {
            path: '/account/settings',
            name: 'settings',
            component: () => import('@/views/account/settings/Index'),
            meta: { title: 'menu.account.settings', hideHeader: true, permission: ['user'] }
          }
        ]
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }
]
